﻿using System;
using System.Data;
using System.Collections;
using CE.Database;

/// <summary>
/// Summary description for MerchantPaymentsDB
/// </summary>
namespace CE.CarInsurance
{
    public class MerchantPaymentsDB
    {
        public Int64 Insert(MerchantPayments merchantpayments)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocMerchantPaymentDetailsInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@PaymentId", merchantpayments.PaymentId);
            _sPara.Add("@QuoteRefNo", merchantpayments.QuoteRefNo);
            _sPara.Add("@CarId", merchantpayments.CarId);
            _sPara.Add("@MerchantId", merchantpayments.MerchantId);
            _sPara.Add("@ProviderCompanyId", merchantpayments.ProviderCompanyId);
            _sPara.Add("@RefCEUserId", merchantpayments.RefCEUserId);
            _sPara.Add("@AgentId", merchantpayments.AgentId);
            _sPara.Add("@AdminId", merchantpayments.AdminId);
            _sPara.Add("@PaymentType", merchantpayments.PaymentType);
            _sPara.Add("@PaymentMode", merchantpayments.PaymentMode);
            _sPara.Add("@PaymentOption", merchantpayments.PaymentOption);
            _sPara.Add("@NoofInstallments", merchantpayments.NoofInstallments);
            _sPara.Add("@PaymentBank", merchantpayments.PaymentBank);
            _sPara.Add("@CollectedAmount", merchantpayments.CollectedAmount);
            _sPara.Add("@AmountwithInterest", merchantpayments.AmountwithInterest);
            _sPara.Add("@TransactionType", merchantpayments.TransactionType);
            _sPara.Add("@ApproveType", merchantpayments.ApproveType);
            _sPara.Add("@PaymentRefNo", merchantpayments.PaymentRefNo);
            _sPara.Add("@CardHolder", merchantpayments.CardHolder);
            _sPara.Add("@IssuingBank", merchantpayments.IssuingBank);
            _sPara.Add("@CreditCardNo", merchantpayments.CreditCardNo);
            _sPara.Add("@CardExpiryMonth", merchantpayments.CardExpiryMonth);
            _sPara.Add("@CardExpiryYear", merchantpayments.CardExpiryYear);
            _sPara.Add("@CardType", merchantpayments.CardType);
            _sPara.Add("@CVV", merchantpayments.CVV);
            _sPara.Add("@IsOnlinePayment", merchantpayments.IsOnlinePayment);
            _sPara.Add("@Status", merchantpayments.Status);
            _sPara.Add("@NoOfDays", merchantpayments.NoOfDays);
            _sPara.Add("@UserTypeId", merchantpayments.UserTypeId);
            _sPara.Add("@Info2", merchantpayments.Info2);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataSet GetPayments(Int64 CarId, Int16 IsOnlinePayment)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            string _spName = "sprocMerchantPaymentsDetailsSelectItemList";

            SortedList _spara = new SortedList();
            _spara.Add("@CarId", CarId);
            _spara.Add("@IsOnlinePayment", IsOnlinePayment);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetPayments(Int64 CarId)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            string _spName = "sprocMerchantPaymentsDetailsSelectItemList";

            SortedList _spara = new SortedList();
            _spara.Add("@CarId", CarId);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }
    }
}
